/* -*- mode: c++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- */

#ifndef _TIMEDO_H_
#define _TIMEDO_H_

#include <utility.h>

#define TIMEDO_BEG(TICKS, COND)                 \
    do {                                        \
        Uint64 __beg = get_ticks();             \
        Uint64 __ticks = TICKS;                 \
        if (COND)                               \

#define TIMEDO_END                              \
        else {                                  \
            Uint64 __now = get_ticks();         \
            if (__now - __beg >= __ticks)       \
                break;                          \
            else                                \
                sleep_us(1);                    \
        }                                       \
    } while (1)

#endif /* _TIMEDO_H_ */
